﻿{% extends "base.html" %}
{% block title %}{{ location.name }}{% endblock %}
{% block before_pagination %}
    <div class="post">
        <div class="meta">
            <a href="{% url myapp.views.announcement_add %}" class="more">dodaj ogłoszenie</a>
        </div>
    </div>
{% endblock %}
{% block sidebar %}
    {% load mptt_tags %}
    <ul>
        <li id="search">
            <h2><b class="text1">Szukaj</b></h2>
            <form method="get" action="/search/">
                <fieldset>
                <input type="text" id="q" name="q" value="" />
                <input type="submit" id="x" value="Szukaj" />
                </fieldset>
            </form>
        </li>
        <li>
            <h2><strong>Wasze</strong> miejsca</h2>
            <ul class="root">
                {% recursetree locations %}
                    <li>
                        <a href="{% url myapp.views.location node.slug %}">{{ node.name }}</a>
                        {% if not node.is_leaf_node %}
                               <i> {{ children }} </i>
                        {% endif %}
                    </li>
                {% endrecursetree %}
            </ul>
        </li>
    </ul>
    <script type="text/javascript">
      function initialize() {
        var lat = "{{ location.lat }}";
        lat = lat.replace(',','.');
        var lng = "{{ location.lng }}";
        lng = lng.replace(',','.');
        var myLatlng = new google.maps.LatLng(lat, lng);
        var myOptions = {
          zoom: 10,
          center: myLatlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        var marker = new google.maps.Marker({
            position: myLatlng, 
            map: map,
            title:"{{ location.name }}"
        });   
      }
      
      function loadScript() {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
        document.body.appendChild(script);
      }
      
      window.onload = loadScript;
    </script>
    <div id="map_canvas" style="height: 250px;width: 250px"></div>
{% endblock %}
